﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace GA_SCHED_DESIGNER
{
    /// <summary>
    /// Interaction logic for SettingsWindow.xaml
    /// </summary>
    public partial class SettingsWindow : Window
    {
        public SettingsWindow()
        {
            InitializeComponent();

            popSizeTxtBox.Text = GA_Scheduler.Properties.Settings.Default.NumberOfChromosomes.ToString();
            eliteTxtBox.Text = GA_Scheduler.Properties.Settings.Default.CountBestChromosomes.ToString();
            crossPointsTxtBox.Text = GA_Scheduler.Properties.Settings.Default.NumberOfCrossoverPoints.ToString();
            crProbabilityTxtBox.Text = GA_Scheduler.Properties.Settings.Default.CrossoverProbability.ToString();
            mutProbabilityTxtBox.Text = GA_Scheduler.Properties.Settings.Default.MutationProbability.ToString();
            workDayNumberTxtBox.Text = GA_Scheduler.Properties.Settings.Default.CountDays.ToString();
            maxDayCoursesTxtBox.Text = GA_Scheduler.Properties.Settings.Default.CountCoursesDaily.ToString();
            maxHoursTxtBox.Text = GA_Scheduler.Properties.Settings.Default.MaxHoursDayily.ToString();
            
            
            GA_Scheduler.PenaltyManager.Load();
            dataGrid1.ItemsSource = GA_Scheduler.PenaltyManager.Penalties;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                GA_Scheduler.Properties.Settings.Default.NumberOfChromosomes = Int32.Parse(popSizeTxtBox.Text);
                GA_Scheduler.Properties.Settings.Default.CountBestChromosomes = Int32.Parse(eliteTxtBox.Text);
                GA_Scheduler.Properties.Settings.Default.NumberOfCrossoverPoints = Int32.Parse(crossPointsTxtBox.Text);
                GA_Scheduler.Properties.Settings.Default.CrossoverProbability = Int32.Parse(crProbabilityTxtBox.Text);
                GA_Scheduler.Properties.Settings.Default.MutationProbability = Int32.Parse(mutProbabilityTxtBox.Text);
                GA_Scheduler.Properties.Settings.Default.CountDays = Int32.Parse(workDayNumberTxtBox.Text);
                GA_Scheduler.Properties.Settings.Default.CountCoursesDaily = Int32.Parse(maxDayCoursesTxtBox.Text);
                GA_Scheduler.Properties.Settings.Default.MaxHoursDayily = Int32.Parse(maxHoursTxtBox.Text);
                
                GA_Scheduler.Properties.Settings.Default.Save();

                GA_Scheduler.PenaltyManager.Save();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        
    }
    
}
